package J11_11;

public class test {

    public static String reverseWord(String s){
        char[] s1 = s.toCharArray();
        String s2 = "";
        for(int i = s.length() - 1;i > -1 ;i--){
            s2 += s1[i];
        }
        return s2;
    }
    public String reverseWords(String s) {
        String s1 = s.trim();
        String s2 = reverseWord(s);
        String[] sArr = s2.split(" ");
        int count = 0;
        String[] sArr2 = new String[1000];
        for(int i = 0;i < sArr.length;i++){
            if(!sArr[i].isEmpty()){
                sArr2[count] = sArr[i];
                count++;
            }
        }
        String s3 = "";
        for(int i = 0; i < count ; i++){
            s3 = s3 +" "+ reverseWord(sArr2[i]);
        }
        return s3.trim();
    }

    public static void main(String[] args) {
        String s = "hello  word";
        System.out.println(reverseWord(s));
    }

}
